****************************************************************************************************
****************************************************************************************************
*Replication file for:
*The Importance of a Liberal Power's Attention to Democratic Elections Around the World
*Johannes Bubeck Ashrakat Elshehawy Nikolay Marinov Federico Nanni
****************************************************************************************************
****************************************************************************************************




*please change to your own working directory
clear
cd "/Data"


*this is the data that was cleaned in DataPrep.do file
use neldaprep

*without microstates
drop if ccode==396 | ccode==232 | ccode==58 | ccode==31 | ccode==53 | ccode==80 | ccode==987 | ccode==55 | ccode==970 | ccode==223 | ccode==212 | ccode==781 | ccode==983 | ccode==221 | ccode==971 | ccode==694 | ccode==56 | ccode==57 | ccode==60 | ccode==990 | ccode==331 | ccode==403 | ccode==591 | ccode==940 | ccode==397 | ccode==940 | ccode==115 | ccode==572 | ccode==972 | ccode==973 | ccode==935

estimates drop _all

*****
*		Table 1 (a) Model (1) 
*****


xi: regress bias uspreselein3 year changed i.ccode if strpos(lower(nelda3),"y")>0 & strpos(lower(nelda4),"y")>0 & strpos(lower(nelda5),"y")>0, robust

*****
*		Table 1 (a) Model (2) 
*****



logit bias1 uspreselein3 changed year if strpos(lower(nelda3),"y")>0 & strpos(lower(nelda4),"y")>0 & strpos(lower(nelda5),"y")>0,robust



*****
*		Table 1 (a) Model (3) 
*****
logit bias9 uspreselein3 changed year if strpos(lower(nelda3),"y")>0 & strpos(lower(nelda4),"y")>0 & strpos(lower(nelda5),"y")>0, robust



*****
*		Table 1 (b) Model (1) 
*****




logit bias3 uspreselein3 changed year if strpos(lower(nelda3),"y")>0 & strpos(lower(nelda4),"y")>0 & strpos(lower(nelda5),"y")>0, robust

*****
*		Table 1 (b) Model (2) 
*****



logit bias4 uspreselein3 changed year if strpos(lower(nelda3),"y")>0 & strpos(lower(nelda4),"y")>0 & strpos(lower(nelda5),"y")>0, robust


*****
*		Table 1 (b) Model (3) 

*****



logit bias5 uspreselein3 changed year if strpos(lower(nelda3),"y")>0 & strpos(lower(nelda4),"y")>0 & strpos(lower(nelda5),"y")>0, robust


*****
*		Table 1 (c) Model (1) 
*****

*Please note about the models that use vdem variables
*the way vdem codes variables is that the higher the number, in that example, the less the electoral irregularities 
*thats why for our purposes we need to reverse the scale for estimates in tables 1 c and d

generate v2elirreg_reversed = v2elirreg*(-1)

xi: regress v2elirreg_reversed  uspreselein3 year changed i.ccode if strpos(lower(nelda3),"y")>0 & strpos(lower(nelda4),"y")>0 & strpos(lower(nelda5),"y")>0, robust



*****
*		Table 1 (c) Model (2) 
*****

generate v2elintim_reversed = v2elintim*(-1)


xi: regress v2elintim_reversed  uspreselein3 year changed i.ccode if strpos(lower(nelda3),"y")>0 & strpos(lower(nelda4),"y")>0 & strpos(lower(nelda5),"y")>0, robust

*****
*		Table 1 (c) Model (3) 
*****

generate v2elpeace_reversed = v2elpeace*(-1)


xi: regress v2elpeace_reversed  uspreselein3 year changed i.ccode if strpos(lower(nelda3),"y")>0 & strpos(lower(nelda4),"y")>0 & strpos(lower(nelda5),"y")>0, robust


*****
*		Table 1 (d) Model (1) 
*****

generate v2elfrfair_reversed = v2elfrfair*(-1)


xi: regress v2elfrfair_reversed  uspreselein3 year changed i.ccode if strpos(lower(nelda3),"y")>0 & strpos(lower(nelda4),"y")>0 & strpos(lower(nelda5),"y")>0, robust

*****
*		Table 1 (d) Model (2) 
*****

generate v2elboycot_reversed = v2elboycot*(-1)


xi: regress v2elboycot_reversed  uspreselein3 year changed i.ccode if strpos(lower(nelda3),"y")>0 & strpos(lower(nelda4),"y")>0 & strpos(lower(nelda5),"y")>0, robust

*****
*		Table 1 (d) Model (3) 
*****

generate v2elfrcamp_reversed = v2elfrcamp*(-1)


xi: regress v2elfrcamp_reversed  uspreselein3 year changed i.ccode if strpos(lower(nelda3),"y")>0 & strpos(lower(nelda4),"y")>0 & strpos(lower(nelda5),"y")>0, robust



*****
*		Table 2 Model (1) 
*****


reghdfe bias uspreselein3 if strpos(lower(nelda3),"y")>0 & strpos(lower(nelda4),"y")>0 & strpos(lower(nelda5),"y")>0, absorb(ccode year) 



*****
*		Table 2 Model (2) 
*****

xi: regress bias uspreselein3 i.decade i.ccode if strpos(lower(nelda3),"y")>0 & strpos(lower(nelda4),"y")>0 & strpos(lower(nelda5),"y")>0, robust


*****
*		Table 2 Model (3) 
*****
*generate month
gen month=month(date)
*fixed effects
gen sq_year=c.year#c.year
gen cub_year=c.year#c.year#c.year

xi: regress bias uspreselein3 year sq_year cub_year month changed i.ccode if strpos(lower(nelda3),"y")>0 & strpos(lower(nelda4),"y")>0 & strpos(lower(nelda5),"y")>0, robust

*****
*		Table 2 Model (4) 
*****

reghdfe bias uspreselein3 year sq_year cub_year month changed i.ccode if strpos(lower(nelda3),"y")>0 & strpos(lower(nelda4),"y")>0 & strpos(lower(nelda5),"y")>0, absorb(ccode) vce(cluster ccode year)






*****
*		Table 3 Model (1) 
*****
xi: regress bias uspreselein3 year changed i.ccode if strpos(lower(nelda3),"y")>0 & strpos(lower(nelda4),"y")>0 & strpos(lower(nelda5),"y")>0, robust

*****
*		Table 3 Model (2) 
*****

xi: regress bias uspreselein3t year changed i.ccode if strpos(lower(nelda3),"y")>0 & strpos(lower(nelda4),"y")>0 & strpos(lower(nelda5),"y")>0, robust

*****
*		Table 3 Model (3) 
*****

xi: regress bias uspreselein3nt year changed i.ccode if strpos(lower(nelda3),"y")>0 & strpos(lower(nelda4),"y")>0 & strpos(lower(nelda5),"y")>0, robust









